home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / VTOOLS / VTWIN.ASM < prev    next >
Assembly Source File  |  1995-02-20  |  6KB  |  217 lines

  1.                 .286
  2. DATA    SEGMENT BYTE PUBLIC
  3.  
  4.  
  5.         EXTRN     VSeg : WORD
  6.         EXTRN     Voff : WORD
  7.         EXTRN   VPageL : WORD
  8. DATA    ENDS
  9.  
  10.  
  11. CODE    SEGMENT BYTE PUBLIC
  12.  
  13.         ASSUME  CS:CODE,DS:DATA
  14.   PUBLIC GetScreen,PutScreen,GetFromScreen,PutToScreen
  15.  
  16. ;============================== GetScrren procedure
  17.   GetScreen proc far
  18.    enter 0,0
  19.     push ds es si di
  20.      mov es,[bp+08d]            ;Load destination
  21.      mov di,[bp+06]
  22.      mov si,Voff                ;Load Video address
  23.      Mov cx,VPageL
  24.      shr cx,1
  25.      mov ax,VSeg
  26.      mov ds,ax
  27.         rep movsw               ;Move all screen to destination
  28.      pop di si es ds
  29.      leave
  30.      retf 4d
  31.   GetScreen Endp
  32. ;============================== PutScreen procedure
  33.   PutScreen proc far
  34.   enter 0,0
  35.    push ds es si di
  36.     mov di,Voff                ;Load Video address
  37.     mov ax,Vseg
  38.     mov es,ax
  39.     mov cx,VPageL
  40.     shr cx,1
  41.     mov ds,[bp+08d]           ;Load and source
  42.     mov si,[bp+06]
  43.        rep movsw              ;Move source to video...
  44.     pop di si es ds
  45.   leave
  46.    retf 4d
  47.   PutScreen Endp
  48.  
  49. ;============================== Get a block from screen
  50.   GetFromScreen proc far
  51.            enter 0,0
  52.     push  es si di ds
  53.  
  54.           mov di,[bp+6]
  55.           mov es,[bp+8]       ;Load destination
  56.  
  57.  
  58.           mov cx,[bp+12d]     ;Load    X1
  59.           mov bx,[bp+14d]     ;Load    Y
  60.  
  61.           dec cx              ;Convert to std coordinates
  62.           dec bx
  63.  
  64.           mov si,Voff         ;Load Destination
  65.           mov ax,Vseg
  66.           mov ds,ax           ;Destination
  67.  
  68.           mov ax,160d
  69.           mul bx
  70.           add si,ax           ;Offset + Y*160
  71.           mov dx,[bp+10d]     ;        Y1
  72.           dec dx              ;Convert to std coordinate
  73.  
  74.  
  75.   GetLine:
  76.  
  77.           mov ax,[bp+16d]    ;Load X
  78.           dec ax             ;Convert to std coordinate
  79.           shl ax,1
  80.           add si,ax          ;Offset = X*2
  81.           shr ax,1
  82.  
  83.   GetChar:                   ;Move line to destination
  84.           Movsw              ;Load Char & attributes
  85.           inc ax
  86.           cmp ax,cx          ;Finish line ?
  87.         jna GetChar          ;No -> Go for next char
  88.  
  89.           sub si,cx          ;Back to the begining of line
  90.           sub si,cx
  91.           sub si,2
  92.           add si,160d        ;Prepare next line
  93.  
  94.           inc bx
  95.           cmp bx,dx          ;Finish Block ?
  96.           jna GetLine        ;No-> Here ya, go for next line
  97.  
  98.      pop ds di si es
  99.            leave
  100.            retf 12d
  101.   GetFromScreen Endp
  102. ;============================== Put a block from screen
  103.   PutToScreen proc far
  104.           enter 0,0
  105.     push  es si di ds
  106.  
  107.           mov di,Voff           ;Load Destination
  108.           mov es,Vseg           ;Destination loaded
  109.  
  110.           mov si,[bp+6]
  111.           mov ds,[bp+8]       ;Load source
  112.  
  113.  
  114.           mov cx,[bp+12d]     ;Load    X1
  115.           mov bx,[bp+14d]     ;Load    Y
  116.  
  117.           dec cx              ;Convert to std coordinates
  118.           dec bx
  119.  
  120.  
  121.           mov ax,160d
  122.           mul bx
  123.           add di,ax           ;Offset + Y*160
  124.           mov dx,[bp+10d]     ;        Y1
  125.           dec dx              ;Convert to std coordinate
  126.  
  127.  
  128.   GetLine1:
  129.           mov ax,[bp+16d]    ;Load X
  130.           dec ax             ;Convert to std coordinate
  131.           shl ax,1
  132.           add di,ax          ;Offset = X*2
  133.           shr ax,1
  134.  
  135.   GetChar1:                  ;Move line to destination
  136.           Movsw              ;Load Char & attributes
  137.           inc ax
  138.           cmp ax,cx          ;Finish line ?
  139.         jna GetChar1         ;No -> Go for next char
  140.  
  141.           sub di,cx          ;Back to the begining of line
  142.           sub di,cx
  143.           sub di,2
  144.           add di,160d        ;Prepare next line
  145.  
  146.           inc bx
  147.           cmp bx,dx          ;Finish Block ?
  148.           jna GetLine1       ;No-> Here ya, go for next line
  149.  
  150.      pop ds di si es
  151.           leave
  152.           retf 16d
  153.   PutToScreen Endp
  154.  
  155. Public CopyScreenBlock
  156.        copyscreenblock proc far
  157.            enter 0,0
  158.            push  es si di ds
  159.                                   ;LOAD DESTINATION
  160.            Mov di,VOff            ;Load offset
  161.            mov ax,[bp+6]
  162.            dec ax
  163.            mov bx,160d
  164.            mul bx
  165.            add di,ax
  166.            mov ax,[bp+8]
  167.            dec ax
  168.            shl ax,1
  169.            add di,ax              ;Offset destination loaded
  170.            mov es,Vseg            ;Load video segment
  171.                                   ;LOAD SOURCE
  172.            mov si,VOff
  173.            mov ax,[bp+14d]        ;Y
  174.            dec ax
  175.            mov bx,160d
  176.            mul bx
  177.            add si,ax
  178.            mov ax,[bp+16d]        ;X
  179.            dec ax
  180.            shl ax,1
  181.            add si,ax
  182.            mov ax,VSeg
  183.            mov ds,ax               ;Source loaded
  184.            mov ax,[bp+16d]         ;Load coordinates
  185.            mov bx,[bp+14d]
  186.            mov dx,[bp+10d]
  187.            cmp ax,[bp+12d]         ; X1 < X ?
  188.            jnb InvalidData         ;Yes -> Exit from procedure
  189.            cmp bx,dx               ;Y1 < Y ?
  190.            jnb InvalidData         ;No -> Continue...
  191.  
  192.    NextL:
  193.            mov cx,[bp+12d]         ;Load X1
  194.            sub cx,ax               ;Line length = X1 - X
  195.            Rep movsw               ;Move line
  196.  
  197.            add si,160d             ;Prepare next line for reading
  198.            sub si,[bp+12d]
  199.            sub si,[bp+12d]
  200.            shl ax,1
  201.            add si,ax
  202.            add di,160d             ;Prepare next line for storing
  203.            sub di,[bp+12d]
  204.            sub di,[bp+12d]
  205.            add di,ax
  206.            shr ax,1
  207.            inc bx                  ;Increment line counter
  208.            cmp bx,dx               ;Finish ?
  209.            jna NextL               ;If no -> Go for next line
  210.    InvalidData :
  211.            pop ds di si es
  212.            leave
  213.           retf 12d
  214.        copyscreenblock endp
  215. CODE ENDS
  216.      END
  217.